<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<%
    String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>征信(重卡传统规则)</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<div style="display:none;">
    <div class="field">
        <!-- 客户主键 -->
        <input name="zx_cstid" id="zx_cstid" type="text" class="ui-textbox" value="${zx_cstid}">
        <!-- 项目主键 -->
        <input name="zx_prjid" id="zx_prjid" type="text" class="ui-textbox" value="${zx_prjid}">
        <!-- 图片服务器根服务 -->
        <input name="zx_pathid" id="zx_pathid" type="text" class="ui-textbox" value="${zx_path}">
        <!-- 担保人主键,是一个JSON数组 -->
        <div name="zx_dbrid" id="zx_dbrid">${zx_dbrid }</div>
    </div>
</div>


<div class="sqPanel">
    <div class="sqPanel_head inL">
        <span>第三方征信(承租人)</span>
    </div>
    <div class="sqPanel_body">
        <div class="sq-staticGrid">
            <c:if test="${zx_flag==1}">
                <table class="table_full">
                    <thead>
                    <tr>
                        <td width="20%">公司名称</td>
                        <td width="10%">状态</td>
                        <td width="40%">描述</td>
                        <td width="30%">操作</td>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <td>信加</td>
                        <td id="xjsId${zx_cstid}">&nbsp;</td>
                        <td id="xjDescId${zx_cstid}">&nbsp;</td>
                        <td id="xjOper" style="text-align:left;padding-left: 20px;">
                            <a href="javascript:;" onclick="refXjData(${zx_cstid},'');">重新查</a>
                            <sys:funcAuth resCd="showRhNpReport">
                              <a href="javascript:;" onclick="xjShow(${zx_cstid},'');">报告</a>
                            </sys:funcAuth>
                        </td>
                    </tr>
                    <tr>
                        <td>三方手机核查</td>
                        <td id="synthmobileId${zx_cstid}">&nbsp;</td>
                        <td id="synthmobileDescId${zx_cstid}">&nbsp;</td>
                        <td id="synthtelOper" style="text-align:left;padding-left: 20px;">
                            <a href="javascript:;" onclick="refSynthTelData(${zx_cstid},'');">重新查</a>
                            <a href="javascript:;" onclick="pysysShow(${zx_cstid},'');">鹏元报告</a>
                            <a href="javascript:;" onclick="tdtelShow(${zx_cstid},'');">同盾报告</a>
                            <a href="javascript:;" onclick="brTelShow(${zx_cstid},'');">百融报告</a>
                        </td>
                    </tr>
                    <tr>
                        <td>三方综合评分</td>
                        <td id="synthscrId${zx_cstid}">&nbsp;</td>
                        <td id="synthscrDescId${zx_cstid}">&nbsp;</td>
                        <td id="synthscrOper" style="text-align:left;padding-left: 20px;">
                            <a href="javascript:;" onclick="refSynthScrData(${zx_cstid},'');">重新查</a>
                            <a href="javascript:;" onclick="jxlShow(${zx_cstid},'');">蜜罐分报告</a>
                            <a href="javascript:;" onclick="tdShow(${zx_cstid},'');">同盾分报告</a>
                            <a href="javascript:;" onclick="brShow(${zx_cstid},'');">百融分报告</a>
                            <%--<a href="javascript:;" onclick="brblShow(${zx_cstid},'');">不良信息报告</a>--%>
                        </td>
                    </tr>
                    <tr>
                        <td>中智诚</td>
                        <td id="zzcsId${zx_cstid}">&nbsp;</td>
                        <td id="zzcDescId${zx_cstid}">&nbsp;</td>
                        <td id="zzcOper" style="text-align:left;padding-left: 20px;">
                            <a href="javascript:;" onclick="refZzcData(${zx_cstid},'');">重新查</a>
                            <a href="javascript:;" onclick="zzcShow(${zx_cstid},'');">报告</a>
                        </td>
                    </tr>
                    <!-- <tr>
                        <td>担保人</td>
                        <td id="dbrsId">&nbsp;</td>
                        <td id="dbrDescId">&nbsp;</td>
                        <td id="dbrOper">
                            <a href="javascript:;" onclick="refDbrData();">重新查</a>
                            <a href="javascript:;" onclick="dbrShow();">报告</a>
                        </td>
                    </tr> -->
                    </tbody>
                </table>
            </c:if>
            <c:if test="${zx_flag==0}">
                <table class="table_full">
                    <thead>
                    <tr>
                        <td width="20%">公司名称</td>
                        <td width="60%">状态</td>
                        <td width="20%">操作</td>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <td>信加</td>
                        <td id="xjsId${zx_cstid}">&nbsp;</td>
                        <td id="xjOper_">
                            <a href="javascript:;" onclick="refXjData(${zx_cstid},'');">重新查</a>
                        </td>
                    </tr>
                    <tr>
                        <td>三方手机核查</td>
                        <td id="synthmobileId${zx_cstid}">&nbsp;</td>
                        <td id="synthtelOper_">
                            <a href="javascript:;" onclick="refSynthTelData(${zx_cstid},'');">重新查</a>
                        </td>
                    </tr>
                    <tr>
                        <td>三方综合评分</td>
                        <td id="synthscrId${zx_cstid}">&nbsp;</td>
                        <td id="synthscrOper_">
                            <a href="javascript:;" onclick="refSynthScrData(${zx_cstid},'');">重新查</a>
                        </td>
                    </tr>
                    <tr>
                        <td>中智诚</td>
                        <td id="zzcsId${zx_cstid}">&nbsp;</td>
                        <td id="zzcOper_">
                            <a href="javascript:;" onclick="refZzcData(${zx_cstid},'');">重新查</a>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </c:if>
        </div>
    </div>
</div>
<!-- 动态数据 -->
<div id="zx_dym_div_id">&nbsp;</div>

<script>
    $(function () {
        var _cstId = $("#zx_cstid").val();
        initData(_cstId, "");//初始化承租人
        refXjData(_cstId, "");//初始化承租人人行信息
//        initDbr();//初始化担保人
    });

    var pathMap = new HashMap();//记录对应的报告路径

    //修改初始化数据
    function initData(_cstId, _typ) {//_typ 分为担保人 还是 承租人
        var _prjId = $("#zx_prjid").val();
        var _url = '<%=path%>/riskctrl/rskctrlcp/getRiskCtrlData.do';
        AjaxUtils.ajaxGet(_url, {prjId: _prjId, cstId: _cstId}, function (msg) {
            if (msg.success == 1) {
                setData(msg.data, _cstId, _typ);//设置数据
            } else {
                //UIUtils.alertError(msg.info);
            }
        });
    }

    //修改时候设置页面数据
    function setData(data, _cstId, _typ) {
        var json = eval(data);
        setSynthTelData(json, _cstId, _typ);
        setSynthScrData(json, _cstId, _typ);
        setZzcData(json, _cstId, _typ);
    };

    //重新查信加数据
    function refXjData(_cstId, _typ) {
        var _prjId = $("#zx_prjid").val();
        var _url = '<%=path%>/riskctrl/rskctrlcp/getXjIsCorrectData.do';
        AjaxUtils.ajaxGet(_url, {prjId: _prjId, cstId: _cstId}, function (msg) {
            if (msg.success == 1) {
                var json = eval(msg.data);
                setXjData(json, _cstId, _typ);
            } else {
                //UIUtils.alertError(msg.info);
            }
        });
    }


    //初始化担保人
    function initDbr() {
        var dbrArrayId = $("#zx_dbrid").html();
        var autoHtml = "";
        $.each(JSON.parse(dbrArrayId), function (index, val) {
            var id = val["id"];
            var typ = "dbr";
            autoHtml += '<div class="zx_dynamic_div" cstId="' + id + '" class="sqPanel">';
            autoHtml += '<div class="sqPanel_head inL">';
            autoHtml += '<span>第三方征信(担保人-' + val["name"] + ')</span>';
            autoHtml += '</div>';
            autoHtml += '<div class="sqPanel_body">';
            autoHtml += '<div class="sq-staticGrid">';
            autoHtml += '<table class="table_full">';
            autoHtml += '<thead>';
            autoHtml += '<tr>';
            autoHtml += '<td width="20%">公司名称</td>';
            autoHtml += '<td width="10%">状态</td>';
            autoHtml += '<td width="50%">描述</td>';
            autoHtml += '<td width="20%">操作</td>';
            autoHtml += '</tr>';
            autoHtml += '</thead>';
            autoHtml += '<tbody>';
            autoHtml += '<tr>';
            autoHtml += '<td>信加</td>';
            autoHtml += '<td id="xjsId' + id + 'dbr">&nbsp;</td>';
            autoHtml += '<td id="xjDescId' + id + 'dbr">&nbsp;</td>';
            autoHtml += '<td id="xjOper' + id + 'dbr" align="left">';
            autoHtml += '<a href="javascript:;" onclick="refXjData(' + id + ',\'' + typ + '\');">重新查</a>';
            autoHtml += '&nbsp;<a href="javascript:;" onclick="xjShow(' + id + ',\'' + typ + '\');">报告</a>';
            autoHtml += '</td>';
            autoHtml += '</tr>';
            autoHtml += '<tr>';
            autoHtml += '<td>三方手机核查</td>';
            autoHtml += '<td id="synthmobileId' + id + 'dbr">&nbsp;</td>';
            autoHtml += '<td id="synthmobileDescId' + id + 'dbr">&nbsp;</td>';
            autoHtml += '<td id="synthmobileOper' + id + 'dbr">';
            autoHtml += '<a href="javascript:;" onclick="refSynthTelData(' + id + ',\'' + typ + '\');">重新查</a>';
            autoHtml += '&nbsp;<a href="javascript:;" onclick="pysysShow(' + id + ',\'' + typ + '\');">鹏元报告</a>';
            autoHtml += '&nbsp;<a href="javascript:;" onclick="tdtelShow(' + id + ',\'' + typ + '\');">同盾报告</a>';
            autoHtml += '&nbsp;<a href="javascript:;" onclick="brTelShow(' + id + ',\'' + typ + '\');">百融报告</a>';
            autoHtml += '</td>';
            autoHtml += '</tr>';
            autoHtml += '<tr>';
            autoHtml += '<td>三方综合评分</td>';
            autoHtml += '<td id="synthscrId' + id + 'dbr">&nbsp;</td>';
            autoHtml += '<td id="synthscrDescId' + id + 'dbr">&nbsp;</td>';
            autoHtml += '<td id="synthscrOper' + id + 'dbr">';
            autoHtml += '<a href="javascript:;" onclick="refSynthscrData(' + id + ',\'' + typ + '\');">重新查</a>';
            autoHtml += '&nbsp;<a href="javascript:;" onclick="jxlShow(' + id + ',\'' + typ + '\');">蜜罐分报告</a>';
            autoHtml += '&nbsp;<a href="javascript:;" onclick="tdShow(' + id + ',\'' + typ + '\');">同盾分报告</a>';
            autoHtml += '&nbsp;<a href="javascript:;" onclick="brShow(' + id + ',\'' + typ + '\');">百融分报告</a>';
            autoHtml += '&nbsp;<a href="javascript:;" onclick="brblShow(' + id + ',\'' + typ + '\');">不良信息报告</a>';
            autoHtml += '</td>';
            autoHtml += '</tr>';
            autoHtml += '<tr>';
            autoHtml += '<td>中智诚</td>';
            autoHtml += '<td id="zzcsId' + id + 'dbr">&nbsp;</td>';
            autoHtml += '<td id="zzcDescId' + id + 'dbr">&nbsp;</td>';
            autoHtml += '<td id="zzcOper' + id + 'dbr">';
            autoHtml += '<a href="javascript:;" onclick="refZzcData(' + id + ',\'' + typ + '\');">重新查</a>';
            autoHtml += '&nbsp;<a href="javascript:;" onclick="zzcShow(' + id + ',\'' + typ + '\');">报告</a>';
            autoHtml += '</td>';
            autoHtml += '</tr>';
            autoHtml += '</tbody>';
            autoHtml += '</table>';
            autoHtml += '</div>';
            autoHtml += '</div>';
            autoHtml += '</div>';
        });

        $("#zx_dym_div_id").empty();
        $("#zx_dym_div_id").html(autoHtml);


        //循环设置数据,有多个担保人的情况,根据客户ID获取数据赋值给担保人
        $(".zx_dynamic_div").each(function () {
            var _cstId = $(this).attr("cstId");
            refXjData(_cstId, "dbr");
            initData(_cstId, "dbr");
        });
    }

    //信加报告
    function xjShow(_cstId, _typ) {
        var key = "xj" + _cstId + _typ;
        var url = pathMap.get(key);
        if (StringUtils.isEmpty(url)) {
            UIUtils.alertWarning("未获取到个人信用报告!");
            return;
        }
        Add_navTab("xj" + key, "个人信用报告", getUrl(url));
    }

    //鹏元三要素手机核查
    function pysysShow(_cstId, _typ) {
        var key = "pysys" + _cstId + _typ;
        var url = pathMap.get(key);
        if (StringUtils.isEmpty(url)) {
            UIUtils.alertWarning("未获取到个人信用报告!");
            return;
        }
        Add_navTab("pysys" + key, "个人信用报告", getUrl(url));
    }

    //聚信立
    function jxlShow(_cstId, _typ) {
        var key = "jxlscr" + _cstId + _typ;
        var url = pathMap.get(key);
        if (StringUtils.isEmpty(url)) {
            UIUtils.alertWarning("未获取到个人信用报告!");
            return;
        }
        Add_navTab("jxl" + key, "个人信用报告", getUrl(url));
    }

    //百融
    function brShow(_cstId, _typ) {
        var key = "brscr" + _cstId + _typ;
        var url = pathMap.get(key);
        if (StringUtils.isEmpty(url)) {
            UIUtils.alertWarning("未获取到个人信用报告!");
            return;
        }
        Add_navTab("br" + key, "个人信用报告", getUrl(url));
    }

    //百融不良信息
    function brblShow(_cstId, _typ) {
        var key = "brbl" + _cstId + _typ;
        var url = pathMap.get(key);
        if (StringUtils.isEmpty(url)) {
            UIUtils.alertWarning("未获取到个人信用报告!");
            return;
        }
        Add_navTab("brbl" + key, "个人信用报告", getUrl(url));
    }

    //百融手机核查
    function brTelShow(_cstId, _typ) {
        var key = "brtel" + _cstId + _typ;
        var url = pathMap.get(key);
        if (StringUtils.isEmpty(url)) {
            UIUtils.alertWarning("未获取到个人信用报告!");
            return;
        }
        Add_navTab("brtel" + key, "个人信用报告", getUrl(url));
    }

    //同盾
    function tdShow(_cstId, _typ) {
        var key = "tdscr" + _cstId + _typ;
        var url = pathMap.get(key);
        if (StringUtils.isEmpty(url)) {
            UIUtils.alertWarning("未获取到个人信用报告!");
            return;
        }
        Add_navTab("td" + key, "个人信用报告", getUrl(url));
    }

    //同盾手机核查
    function tdtelShow(_cstId, _typ) {
        var key = "tdtel" + _cstId + _typ;
        var url = pathMap.get(key);
        if (StringUtils.isEmpty(url)) {
            UIUtils.alertWarning("未获取到个人信用报告!");
            return;
        }
        Add_navTab("tdtel" + key, "个人信用报告", getUrl(url));
    }

    //中智诚报告
    function zzcShow(_cstId, _typ) {
        var key = "zzc" + _cstId + _typ;
        var url = pathMap.get(key);
        if (StringUtils.isEmpty(url)) {
            UIUtils.alertWarning("未获取到个人信用报告!");
            return;
        }
        Add_navTab("zzc" + key, "个人信用报告", getUrl(url));
    }

    //重新查三方手机核查
    function refSynthTelData(_cstId, _typ) {
        var _prjId = $("#zx_prjid").val();
        var _url = '<%=path%>/riskctrl/rskctrlcp/getSynthMobileIsCorrectData.do';
        AjaxUtils.ajaxGet(_url, {prjId: _prjId, cstId: _cstId}, function (msg) {
            if (msg.success == 1) {
                var json = eval(msg.data);
                setSynthTelData(json, _cstId, _typ);
            } else {
                UIUtils.alertError(msg.info);
            }
        });
    }

    //重新查三方综合分数据
    function refSynthScrData(_cstId, _typ) {
        var _prjId = $("#zx_prjid").val();
        var _url = '<%=path%>/riskctrl/rskctrlcp/getSynthScoreIsCorrectData.do';
        AjaxUtils.ajaxGet(_url, {prjId: _prjId, cstId: _cstId}, function (msg) {
            if (msg.success == 1) {
                var json = eval(msg.data);
                setSynthScrData(json, _cstId, _typ);
            } else {
                UIUtils.alertError(msg.info);
            }
        });
    }

    //重新查中智诚数据
    function refZzcData(_cstId, _typ) {
        var _prjId = $("#zx_prjid").val();
        var _url = '<%=path%>/riskctrl/rskctrlcp/getZZCIsCorrectData.do';
        AjaxUtils.ajaxGet(_url, {prjId: _prjId, cstId: _cstId}, function (msg) {
            if (msg.success == 1) {
                var json = eval(msg.data);
                setZzcData(json, _cstId, _typ);
            } else {
                UIUtils.alertError(msg.info);
            }
        });
    }

    //设置中智诚数据
    function setZzcData(json, _cstId, _typ) {
        pathMap.remove("zzc" + _cstId + _typ);//先删除
        if ("false" == json["zzchmd-pass"]) {//中智诚黑名单
            $("#zzcsId" + _cstId + _typ).html("<font color='#D70000'>拒单</font>");
        } else if ("true" == json["zzchmd-pass"]) {
            $("#zzcsId" + _cstId + _typ).html("<font color='#00A900'>通过</font>");
        } else if ("review" == json["zzchmd-pass"]) {
            $("#zzcsId" + _cstId + _typ).html("<font color='#D70000'>复议</font>");
        } else if ("true" == json["zzchmd-exception"]) {
            $("#zzcsId" + _cstId + _typ).html("<font color='#D70000'>异常</font>");
        } else {
            $("#zzcsId" + _cstId + _typ).html("<font color='#D70000'>未知</font>");
        }
        $("#zzcDescId" + _cstId + _typ).html(json["zzchmd"]);
        pathMap.put("zzc" + _cstId + _typ, json["zzchmd-path"]);
    }

    //设置三方综合评分数据
    function setSynthScrData(json, _cstId, _typ) {
        pathMap.remove("synthscr" + _cstId + _typ);//先删除
        if ("false" == json["synthscr-pass"]) {
            $("#synthscrId" + _cstId + _typ).html("<font color='#D70000'>拒单</font>");
        } else if ("true" == json["synthscr-pass"]) {
            $("#synthscrId" + _cstId + _typ).html("<font color='#00A900'>通过</font>");
        } else if ("review" == json["synthscr-pass"]) {
            $("#synthscrId" + _cstId + _typ).html("<font color='#D70000'>复议</font>");
        } else if ("true" == json["synthscr-exception"]) {
            $("#synthscrId" + _cstId + _typ).html("<font color='#D70000'>异常</font>");
        } else {
            $("#synthscrId" + _cstId + _typ).html("<font color='#D70000'>未知</font>");
        }
        $("#synthscrDescId" + _cstId + _typ).html(json["synthscr"]);
        pathMap.put("jxlscr" + _cstId + _typ, json["jxlscr-path"]);
        pathMap.put("tdscr" + _cstId + _typ, json["tdscr-path"]);
        pathMap.put("brscr" + _cstId + _typ, json["brscr-path"]);
        pathMap.put("brbl" + _cstId + _typ, json["brbl-path"]);
    }

    //设置三方手机核查数据
    function setSynthTelData(json, _cstId, _typ) {
        pathMap.remove("synthmobile" + _cstId + _typ);//先删除
        if ("false" == json["synthmobile-pass"]) {
            $("#synthmobileId" + _cstId + _typ).html("<font color='#D70000'>拒单</font>");
        } else if ("true" == json["synthmobile-pass"]) {
            $("#synthmobileId" + _cstId + _typ).html("<font color='#00A900'>通过</font>");
        } else if ("review" == json["synthmobile-pass"]) {
            $("#synthmobileId" + _cstId + _typ).html("<font color='#D70000'>复议</font>");
        } else if ("true" == json["brtel-exception"]) {
            $("#synthmobileId" + _cstId + _typ).html("<font color='#D70000'>异常</font>");
        } else {
            $("#synthmobileId" + _cstId + _typ).html("<font color='#D70000'>未知</font>");
        }
        $("#synthmobileDescId" + _cstId + _typ).html(json["synthmobile"]);
        pathMap.put("pysys" + _cstId + _typ, json["pysys-path"]);
        pathMap.put("tdtel" + _cstId + _typ, json["tdtel-path"]);
        pathMap.put("brtel" + _cstId + _typ, json["brtel-path"]);
    }

    //设置信加数据
    function setXjData(json, _cstId, _typ) {
        pathMap.remove("xj" + _cstId + _typ);//先删除
        if ("false" == json["xj-pass"]) {
            $("#xjsId" + _cstId + _typ).html("<font color='#D70000'>拒单</font>");
        } else if ("true" == json["xj-pass"]) {
            $("#xjsId" + _cstId + _typ).html("<font color='#00A900'>通过</font>");
        } else if ("review" == json["xj-pass"]) {
            $("#xjsId" + _cstId + _typ).html("<font color='#D70000'>复议</font>");
        } else if ("true" == json["xj-exception"]) {
            $("#xjsId" + _cstId + _typ).html("<font color='#D70000'>异常</font>");
        } else {
            $("#xjsId" + _cstId + _typ).html("<font color='#D70000'>未知</font>");
        }
        $("#xjDescId" + _cstId + _typ).html(json["xj"]);
        pathMap.put("xj" + _cstId + _typ, json["xj-path"]);
    }

    //返回完整路径
    function getUrl(url) {
        var p = $("#zx_pathid").val();
        return p + url;
    }
</script>
</body>
</html>